package com.lemon.test;

import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lemon.dao.EmployeeDao;
import com.lemon.domain.Authorize;
import com.lemon.domain.Department;
import com.lemon.domain.Employee;
import com.lemon.domain.Menu;
import com.lemon.domain.Role;
import com.lemon.service.AuthorizeService;
import com.lemon.service.DepartmentService;
import com.lemon.service.EmployeeService;
import com.lemon.service.MenuService;
import com.lemon.service.RoleService;

public class Demo {

	@Test
	public void m1() {
		EmployeeDao dao = new EmployeeDao();
		List<Employee> list = dao.findEmployeesByDepartmentId(1L);
	}
	
	@Test
	public void m2() {
		DepartmentService service = new DepartmentService();
		String html = service.listToHtml(service.listSubDapartment(-1L));
		System.out.println(html);
	}
	
	@Test
	public void m3() {
		DepartmentService service = new DepartmentService();
		Department department = service.get(1L);
		String jsonString = JSONObject.toJSONString(department);
		Map<String, Object> json = JSON.parseObject(jsonString, Map.class);
		System.out.println(json);
	}
	
	@Test
	public void m4() {
		MenuService service = new MenuService();
		List<Menu> list = service.listSubmenu(-1L);
	}
	
	@Test
	public void m5() {
		MenuService service = new MenuService();
		List<Menu> list = service.listSubmenu(null);
		System.out.println(list);
		for (Menu menu : list) {
			System.out.println(menu);
		}
	}
	
	@Test
	public void m6() {
		AuthorizeService service = new AuthorizeService();
		Authorize a = new Authorize();
		service.save(a);
	}
	
	@Test
	public void m7() {
		RoleService service = new RoleService();
		Role role = service.get(4L);
		System.out.println(role.getAuthorize());
	}
	
	@Test
	public void m8() {
		EmployeeService service = new EmployeeService();
		Employee e = new Employee();
		e.setId(2L);
		e.setRoleId(1L);
		service.addRole(e);
	}
}
